<?php

use App\Http\Controllers\AttachmentController;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\CarrierController;
use Illuminate\Support\Facades\Route;
// 后台admin端路由
Route::prefix('admin')->group(function() {
    // 注册用户
    Route::post('register',[AuthController::class,'register']);
    // 登录
    Route::post('login',[AuthController::class,'login']);

    // 需要auth验证
    Route::group(['middleware' => ['auth:sanctum']],function() {

        // -------------------S用户-------------------
        // 退出注销账号
        Route::post('logout',[AuthController::class,'logout']);
        // 获取用户资料
        Route::get('get_user',function() {
            return auth()->user();
        });
        Route::put('update_account',[AuthController::class,'update']);
        // -------------------E用户-------------------

        // -------------------S素材库-------------------
        Route::prefix('attachment')->group(function() {
            // 上传素材
            Route::post('upload',[AttachmentController::class,'upload']);
            // 获取素材列表
            Route::get('getList',[AttachmentController::class,'getList']);
            // 获取素材附件前缀链接
            Route::get('getAttachmentUrl',[AttachmentController::class,'getAttachmentUrl']);
            // 删除素材附件
            Route::delete('delete/{attachment_id}',[AttachmentController::class,'delete']);
        });
        // -------------------E素材库-------------------

        // -----------------S平台---------------------------
        Route::resource('carrier',CarrierController::class);
        // -----------------E平台---------------------------
    });
});
